package com.hall.item.item.web;



import com.hall.item.item.pojo.ItemDoc;
import com.hall.item.item.pojo.RequestParams;
import com.hall.item.item.service.SearchService;
import com.hmall.common.dto.PageDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("item")
public class SearchController {

    @Autowired
    private SearchService searchService;

    @GetMapping("/suggestion")
    public List<String> getSuggestion(@RequestParam("key") String key){
        return searchService.getSuggestion(key);
    }


    @PostMapping("/filters")
    public Map<String,List<String>> getFilters(@RequestBody RequestParams params){
        return searchService.getFilters(params);
    }

    @PostMapping("/list")
    public PageDTO<ItemDoc> queryList(@RequestBody RequestParams params){
        return searchService.queryList(params);
    }
}

